package com.java.util;

import lombok.Data;

import java.util.Objects;


@Data
public class FilterOverviewModel {
    private Long id;

    // 错误实现：只比较当前类，且允许与子类比较时返回 true
    @Override
    public boolean equals(Object o) {
        if (!(o instanceof FilterOverviewModel)) {
            return false;
        }
        FilterOverviewModel other = (FilterOverviewModel) o;
        return Objects.equals(this.id, other.id);
    }

    // 修改为下面实现，确保只比较当前类的 id，getClass() != o.getClass()
    /*@Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        FilterOverviewModel that = (FilterOverviewModel) o;
        return Objects.equals(id, that.id);
    }*/

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
